import React from 'react';
import { Toast, } from 'antd-mobile';

export default class Index extends React.Component {
    constructor(props){
        super(props)
        this.state={
            img: '',
            rm: [],
            mxf_product: [],
            mxf_active: [],
            kind_id: '',
            product: [],
		}
    }
	componentDidMount(){
        document.title = ''
        this.getInfo()
	}
	getInfo(){
		global.Ajax.hhtc_request("yl/infos",{}).then(data=>{
			if(data.code===1){
                this.setState(data.data)
            }
		})
	}
	render(){
		return(
			<div style={{minHeight: '100vh',background: '#F5F5F5',paddingBottom: 1,}}>
                <img alt='' src={this.state.img} className='dra_top_img' />
                <div className='dra_title'>
                    <img alt='' src={require('../../imgs/caid.png')} />
                    <h1>分享得回馈</h1>
                    <img alt='' src={require('../../imgs/caid1.png')} />
                </div>
                <p className='dra_desc'>分享好友并购买9.9元入门级课程包<br />获得9.9元回馈奖励！</p>
                <div className='rm_list'>
                    {this.state.rm.map((item,index)=>(
                        <div className='rm_item' key={'i'+index} onClick={()=>{this.props.history.push('/page/home/learn/learndetail/'+item.id)}}>
                            <img alt='' src={item.img} />
                            <h2>{item.title}</h2>
                            <p className='desc'>{item.info}</p>
                            <div className='flex'>
                                <p>{item.z_price}元</p>
                                <span>查看详情</span>
                            </div>
                        </div>
                    ))}
                </div>
                <div className='dra_title'>
                    <img alt='' src={require('../../imgs/caid.png')} />
                    <h1>课程免费学</h1>
                    <img alt='' src={require('../../imgs/caid1.png')} />
                </div>
                <p className='dra_desc'>购买课程后分享该课程给2个好友并购买<br />即可获得100%的现金回馈！</p>
                <div className='rm_list'>
                    {this.state.mxf_product.map((item,index)=>(
                        <div className='rm_item' key={'i'+index} onClick={()=>{this.props.history.push('/page/home/learn/learndetail/'+item.id)}}>
                            <img alt='' src={item.img} />
                            <h2>{item.title}</h2>
                            <p className='desc'>{item.info}</p>
                            <div className='flex'>
                                <p>{item.z_price}元</p>
                                <span>查看详情</span>
                            </div>
                        </div>
                    ))}
                </div>
                <p className='xk_title'>线下课程</p>
                <div className='xkc_list'>
                    {this.state.mxf_active.map((item,index)=>(
                        <div className='xkc_item' key={'x'+index} onClick={()=>{this.props.history.push('/page/home/signup/detail/'+item.id)}}>
                            <img alt='' src={item.img} />
                            <div className='info'>
                                <h1>{item.title}</h1>
                                <p className='desc'>{item.info}</p>
                                <p className='ren'>主讲人：{item.name}</p>
                                <p className='time'>授课时间：{item.time}</p>
                            </div>
                        </div>
                    ))}
                </div>
                <div className='dra_title'>
                    <img alt='' src={require('../../imgs/caid.png')} />
                    <h1>年费会员</h1>
                    <img alt='' src={require('../../imgs/caid1.png')} />
                </div>
                <p className='dra_desc'>购买课程后分享该课程给2个好友并购买<br />即可获得100%的现金回馈！</p>
                <p className='go_vip' onClick={()=>{this.props.history.push('/page/home/user/payvip')}}>开通年费会员</p>
                <div className='title_box'>
                    <h1>年费会员免费学</h1>
                    <p onClick={()=>{this.props.history.push('/page/home/home/classify/'+this.state.kind_id)}}>
                        <span>更多</span>
                        <img alt='' src={require('../../imgs/r2.png')} />
                    </p>
                </div>
                <div className='sy_list'>
                    {this.state.product.map((child,k)=>{
                        return(
                            <div className='item' key={'child'+k} onClick={()=>{this.props.history.push('/page/home/learn/learndetail/'+child.id)}}>
                                <div className='picbox'>
                                    <img alt='' src={child.img} className='pic' />
                                    <p className='bq'>{child.type===1?'视频':'听书'}</p>
                                </div>
                                <p className='title'>{child.title}</p>
                            </div>
                        )
                    })}
                </div>
			</div>
		)
	}
}
